package org.inspursc.s0517.health.common.service.impl;

import lombok.extern.slf4j.Slf4j;
import org.inspursc.s0517.health.common.dao.SysGroupRoleDao;
import org.inspursc.s0517.health.common.entity.SysGroupRole;

import org.inspursc.s0517.health.common.service.SysGroupRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class SysGroupRoleServiceImpl implements SysGroupRoleService {

    @Autowired
    private SysGroupRoleDao groupRoleDao;

    @Override
    public SysGroupRole save(SysGroupRole groupRole) {
        return groupRoleDao.save(groupRole);
    }

    @Override
    public SysGroupRole findById(Integer id) {
        return groupRoleDao.getOne(id);
    }

    @Override
    public boolean deleteById(Integer id) {
        try {
            groupRoleDao.deleteById(id);
            return true;
        } catch (Exception e) {
            log.error("【删除失败】", e.getMessage());
            return false;
        }
    }

    @Override
    public List<SysGroupRole> findBySysRoleId(Integer roleId) {
        return groupRoleDao.findBySysRoleId(roleId);
    }
}
